var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("GameEm"),
    s = t("ShopGroupItemBase"),
    c = cc._decorator,
    p = c.ccclass,
    l =
        (c.property,
        c.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.checkWeekCost = 0;
                e.checkMouthCost = 0;
                e.parseKey = "";
                e.addZSCount = 0;
                e.spriteIcon = "";
                e.timeMouth = 0;
                e.timeWeek = 0;
                return e;
            }
            e.prototype.onShowEnd = function () {
                this.updateList();
                this.node.active && this.checkView();
            };
            e.prototype.onLoad = function () {};
            e.prototype.setRender = function (t, e) {
                for (var o = t.getComponentsInChildren(cc.RenderComponent), a = 0; a < o.length; a++)
                    CacheDataManager.setSpriteMat(o[a], e);
            };
            e.prototype.checkView = function () {
                this._tip.$Label.string = this.tipNodeId;
                if (2 == this.checkList.length) {
                    if (PayData.getCanMouth()) {
                        this._mouthBtnBg.active = !0;
                        var t = PayData.getMouthCount(),
                            e = 30;
                        this._cardDay1.$Label.string = "(累计领取:" + (e - t) + "/" + e + "次)";
                        if (this.checkBtnCanClick(this.getCardMonthLastList(e - t, e))) {
                            this.setRender(this._mouthBtnBg, !0);
                            this._costBtnLab1.$Label.string = "领取奖励";
                        } else {
                            this.setRender(this._mouthBtnBg, !1);
                            this._costBtnLab1.$Label.string = "已领取";
                        }
                    } else {
                        this._mouthBtnBg.active = !1;
                        this._cardDay1.$Label.string = "";
                        this._costBtnLab1.$Label.string = "￥" + this.checkList[0].cash;
                    }
                    if (PayData.getCanWeak()) {
                        this._weekBtnBg.active = !0;
                        (t = PayData.getWeakCount()), (e = 7);
                        this._cardDay2.$Label.string = "(累计领取:" + (e - t) + "/" + e + "次)";
                        if (this.checkBtnCanClick(this.getCardWeekLastList(e - t, e))) {
                            this.setRender(this._weekBtnBg, !0);
                            this._costBtnLab2.$Label.string = "领取奖励";
                        } else {
                            this.setRender(this._weekBtnBg, !1);
                            this._costBtnLab2.$Label.string = "已领取";
                        }
                    } else {
                        this._weekBtnBg.active = !1;
                        this._cardDay2.$Label.string = "";
                        this._costBtnLab2.$Label.string = "￥" + this.checkList[1].cash;
                    }
                }
            };
            e.prototype.getCardMonthLastList = function (t, e) {
                var o = [],
                    a = (CacheDataManager.getShopDataCof().shop[20161].products_daily + "").split("_"),
                    i = parseInt(a[1]);
                this.addZSCount = i;
                for (var n = PayData.getTodayMouth(), r = 0; r < e; r++) {
                    var s = !PayData.getMonthIsGetReward(r),
                        c = t == r && n;
                    o.push({id: r, count: i, old: r < t, isOver: c, canReward: s});
                }
                return o;
            };
            e.prototype.getCardWeekLastList = function (t, e) {
                var o = [],
                    a = (CacheDataManager.getShopDataCof().shop[20162].products_daily + "").split("_"),
                    i = parseInt(a[1]);
                this.addZSCount = i;
                for (var n = PayData.getTodayWeek(), r = 0; r < e; r++) {
                    var s = !PayData.getWeekIsGetReward(r),
                        c = t == r && n;
                    o.push({id: r, count: i, old: r < t, isOver: c, canReward: s});
                }
                return o;
            };
            e.prototype.checkBtnCanClick = function (t) {
                for (var e = !1, o = 0; o < t.length; o++) t[o].isOver && t[o].canReward && (e = !0);
                return e;
            };
            e.prototype._onItem1TouchEnd = function () {
                var t = this,
                    e = this._item1.convertToWorldSpaceAR(cc.Vec2.ZERO);
                if (!(Date.now() - this.timeMouth < 1e3)) {
                    this.timeMouth = Date.now();
                    if (PayData.getCanMouth()) {
                        if (this.checkBtnCanClick(this.getCardMonthLastList(30 - PayData.getMouthCount(), 30))) {
                            var o = PayData.getMouthMaxCount(30);
                            PayData.getMouthCount();
                            if (o < 30) {
                                PayData.addPropData(r.RewardResKind.zhuanShi, this.addZSCount, e, "2");
                                PayData.setMonthIsGetReward(o);
                                var a = {resId: this.parseKey, count: 0, type: 2, tip: "月卡", tip2: "每天领取"};
                                console.log("UICardDlg --------月--------- 完成" + this.addZSCount);
                                PayData.addLog(
                                    a.resId,
                                    a.count,
                                    a.type,
                                    [{id: 1, num: this.addZSCount}],
                                    a.tip,
                                    a.tip2
                                );
                            }
                            this.checkView();
                        }
                    } else {
                        var i = cc.v2(e).add(cc.v2(-300, 700));
                        this.spriteIcon = this.allKeyList[0];
                        this.parseKey = this.spriteIcon;
                        PayData.checkPayCost(this.checkWeekCost)
                            ? PayData.addPayData(
                                  this.parseKey,
                                  this.checkWeekCost,
                                  function (o) {
                                      if (o) {
                                          QReport.send("220161");
                                          var a = {
                                                  resId: t.parseKey,
                                                  count: t.checkWeekCost,
                                                  type: 2,
                                                  tip: "月卡",
                                                  tip2: ""
                                              },
                                              n = t.addImReward(e, t.checkList[0].products.split("|"));
                                          PayData.openMouth();
                                          n.push({id: 4, num: 1});
                                          EVUIEffView.emit(EVUIEffView.movePropSpriteIcon, e, i, t.spriteIcon);
                                          PayData.addLog(a.resId, a.count, a.type, n, a.tip, a.tip2);
                                          t.checkView();
                                      }
                                  },
                                  [{id: 4, num: 1, pid: this.parseKey}]
                              )
                            : console.log("ShopGroupItem01 ----------------- 价格不够");
                    }
                }
            };
            e.prototype._onItem2TouchEnd = function () {
                var t = this,
                    e = this._item2.convertToWorldSpaceAR(cc.Vec2.ZERO);
                if (!(Date.now() - this.timeWeek < 1e3)) {
                    this.timeWeek = Date.now();
                    if (PayData.getCanWeak()) {
                        if (this.checkBtnCanClick(this.getCardWeekLastList(7 - PayData.getWeakCount(), 7))) {
                            var o = PayData.getWeekMaxCount(7);
                            if (o < 7) {
                                PayData.setWeekIsGetReward(o);
                                PayData.getWeakCount();
                                for (
                                    var a = this.checkList[1].products_daily.split("|"),
                                        i = cc.v2(e).add(cc.v2(-100, 1300)),
                                        n = [],
                                        r = 0;
                                    r < a.length;
                                    r++
                                ) {
                                    var s = a[r].split("_");
                                    if (s.length > 0)
                                        if ("2" == s[0]) {
                                            n.push({id: 1, num: 1});
                                            EVUIEffView.emit(EVUIEffView.moveZhuanShi, e, 2, s[1] + "", "2");
                                        } else
                                            switch (s[0]) {
                                                case "5":
                                                case "6":
                                                case "7":
                                                    var c = CacheDataManager.getRewardKind(s[0]);
                                                    if (c) {
                                                        n.push({id: s[0], num: s[1]});
                                                        EVUIEffView.emit(
                                                            EVUIEffView.movePropSpriteIcon,
                                                            e,
                                                            i,
                                                            c.icon,
                                                            !0
                                                        );
                                                        GameDataValue.setShopKey(
                                                            s[0],
                                                            GameDataValue.getShopKey(s[0]) + parseInt(s[1])
                                                        );
                                                    }
                                            }
                                }
                                var p = {
                                    resId: this.parseKey,
                                    count: this.checkWeekCost,
                                    type: 2,
                                    tip: "周卡",
                                    tip2: ""
                                };
                                PayData.addLog(p.resId, p.count, p.type, n, p.tip, p.tip2);
                                this.checkView();
                            }
                        }
                    } else {
                        this.spriteIcon = this.allKeyList[1];
                        this.parseKey = this.spriteIcon;
                        if (PayData.checkPayCost(this.checkWeekCost)) {
                            var l = cc.v2(e).add(cc.v2(-300, 700));
                            PayData.addPayData(
                                this.parseKey,
                                this.checkWeekCost,
                                function (o) {
                                    if (o) {
                                        QReport.send("220162");
                                        var a = {
                                                resId: t.parseKey,
                                                count: t.checkWeekCost,
                                                type: 2,
                                                tip: "周卡",
                                                tip2: ""
                                            },
                                            i = t.addImReward(e, t.checkList[1].products.split("|"));
                                        i.push({id: 4, num: 1});
                                        PayData.openWeak();
                                        EVUIEffView.emit(EVUIEffView.movePropSpriteIcon, e, l, t.spriteIcon);
                                        PayData.addLog(a.resId, a.count, a.type, i, a.tip, a.tip2);
                                        t.checkView();
                                    }
                                },
                                [{id: 4, num: 1, pid: this.parseKey}]
                            );
                        } else console.log("ShopGroupItem01 ----------------- 价格不够");
                    }
                }
            };
            e.prototype.addImReward = function (t, e) {
                for (var o = [], a = 0; a < e.length; a++) {
                    var i = e[a].split("_");
                    if (i.length > 0 && "2" == i[0]) {
                        o.push({id: 1, num: i[1]});
                        EVUIEffView.emit(EVUIEffView.moveZhuanShi, t, 2, i[1] + "", "2");
                    }
                }
                return o;
            };
            return n([p], e);
        })(s.default));
o.default = l;
